const Tesseract = require('tesseract.js');
const path = require('path');
const { PNG } = require('pngjs');
const fs = require("fs");

// 图片路径列表
const imagePaths = [
    // path.join(__dirname, 'kdj.png'),
    path.join(__dirname, 'kdj.png'),
    path.join(__dirname, 'arbr.png'),
    // 添加更多图片路径...
];

// 识别单个图片
async function recognizeImage(imagePath) {
    try {
        const { data: { text } } = await Tesseract.recognize(
            imagePath,
            'eng', // 确保你有安装英文语言包
        );

        console.log(`图片 ${imagePath} 的识别结果:`, text.trim());
    } catch (err) {
        console.error(`图片 ${imagePath} 识别失败:`, err);
    }
}

// 批量识别图片
async function recognizeMultipleImages(imagePaths) {
    for (const imagePath of imagePaths) {
        await recognizeImage(imagePath);
    }
}

recognizeMultipleImages(imagePaths);

